<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>权益明账通 - 大学生消费维权平台</title>
    <style>
        /* 全局样式 */
        body {
            font-family: 'Helvetica Neue', Arial, sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f5f7fa;
            color: #333;
        }

        /* 导航菜单 */
        .main-nav {
            background-color: #1976d2;
            padding: 1rem;
            position: sticky;
            top: 0;
            z-index: 100;
        }

        .main-nav ul {
            display: flex;
            list-style: none;
            margin: 0;
            padding: 0;
            justify-content: center;
        }

        .main-nav li {
            margin: 0 1rem;
        }

        .main-nav a {
            color: white;
            text-decoration: none;
            font-weight: 500;
            padding: 0.5rem 1rem;
            border-radius: 4px;
            transition: all 0.3s;
        }

        .main-nav a:hover {
            background-color: rgba(255, 255, 255, 0.2);
            transform: translateY(-2px);
        }

        .main-nav .active a {
            background-color: rgba(255, 255, 255, 0.3);
            box-shadow: 0 2px 5px rgba(0,0,0,0.2);
        }

        /* 项目介绍区域 */
        .intro {
            text-align: center;
            padding: 4rem 1rem;
            background: linear-gradient(135deg, #1976d2, #2196f3);
            color: white;
        }

        .intro h1 {
            font-size: 2.5rem;
            margin-bottom: 1rem;
            text-shadow: 1px 1px 3px rgba(0,0,0,0.2);
        }

        .intro p {
            font-size: 1.2rem;
            max-width: 800px;
            margin: 0 auto;
            line-height: 1.6;
        }

        /* 知识板块标题 */
        .section-title {
            text-align: center;
            padding: 3rem 1rem 1rem;
            background-color: #f5f7fa;
        }

        .section-title h2 {
            font-size: 2.2rem;
            color: #1976d2;
            margin-bottom: 0.5rem;
            position: relative;
            display: inline-block;
        }

        .section-title h2::after {
            content: '';
            position: absolute;
            bottom: -10px;
            left: 50%;
            transform: translateX(-50%);
            width: 80px;
            height: 3px;
            background: linear-gradient(90deg, #1976d2, #2196f3);
            border-radius: 2px;
        }

        .section-title .subtitle {
            font-size: 1.1rem;
            color: #666;
            max-width: 600px;
            margin: 0 auto;
        }

        /* 视频区域 */
        .video-container {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
            gap: 1.5rem;
            padding: 2rem;
            max-width: 1200px;
            margin: 0 auto;
            background-color: #f5f7fa;
        }

        .video-wrapper {
            background: white;
            border-radius: 12px;
            overflow: hidden;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
            transition: transform 0.3s;
        }

        .video-wrapper:hover {
            transform: translateY(-5px);
        }

        .video-wrapper video {
            width: 100%;
            display: block;
            border-bottom: 1px solid #eee;
        }

        .video-caption {
            padding: 1rem;
            text-align: center;
            font-size: 0.9rem;
            color: #666;
        }

        /* 加载动画 */
        .loading {
            text-align: center;
            padding: 2rem;
            color: #666;
        }

        .loading::after {
            content: '...';
            animation: dots 1.5s steps(4, end) infinite;
        }

        @keyframes dots {
            0%, 20% { color: rgba(0,0,0,0); text-shadow: .25em 0 0 rgba(0,0,0,0), .5em 0 0 rgba(0,0,0,0); }
            40% { color: #666; text-shadow: .25em 0 0 rgba(0,0,0,0), .5em 0 0 rgba(0,0,0,0); }
            60% { text-shadow: .25em 0 0 #666, .5em 0 0 rgba(0,0,0,0); }
            80%, 100% { text-shadow: .25em 0 0 #666, .5em 0 0 #666; }
        }

        /* 移动端适配 */
        @media (max-width: 768px) {
            .main-nav ul {
                flex-wrap: wrap;
            }
            .main-nav li {
                margin: 0.5rem;
            }
            .video-container {
                grid-template-columns: 1fr;
                padding: 1rem;
            }

            .intro h1 {
                font-size: 2rem;
            }

            .section-title h2 {
                font-size: 1.8rem;
            }
        }
    </style>
</head>
<body>
<!-- 导航菜单 -->
<nav class="main-nav">
    <ul>
        <li class="active"><a href="./index.html">首页</a></li>
        <li><a href="./calculator.html">智能计算</a></li>
        <li><a href="./volunteer.html">志愿者平台</a></li>
        <li><a href="./AIassistant.html">全能智慧助手</a></li>
    </ul>
</nav>

<!-- 项目介绍 -->
<section class="intro">
    <h1>权益明账通</h1>
    <p>专为大学生打造的消费维权平台，提供智能账单分析、消费维权指导和志愿者协助服务，让每一笔消费都明明白白</p>
</section>

<!-- 知识板块标题 -->
<div class="section-title">
    <h2>消费维权公益知识板块</h2>
    <p class="subtitle">学习消费权益知识，提升维权意识，保护自身合法权益</p>
</div>
<!-- 在视频容器上方添加刷新按钮 -->
<div style="text-align: center; padding: 1rem;">
    <button onclick="refreshVideos()" style="padding: 0.5rem 1rem; background: #1976d2; color: white; border: none; border-radius: 4px; cursor: pointer;">
        刷新视频列表
    </button>
</div>
<!-- 视频展示区 -->
<div class="video-container" id="videoContainer">
    <div class="loading">视频加载中</div>
</div>

<script>
    // 当前页面导航高亮
    document.addEventListener('DOMContentLoaded', function() {
        // 导航交互
        const navItems = document.querySelectorAll('.main-nav li');
        navItems.forEach(item => {
            item.addEventListener('click', function() {
                navItems.forEach(i => i.classList.remove('active'));
                this.classList.add('active');
            });
        });

        // 加载视频数据
        loadVideos();
    });

    // 从后端获取视频数据
    async function loadVideos() {
        try {
            // 这里替换为您的实际API地址
            const response = await fetch('/api/videos');
            const result = await response.json();

            if (result.code === 200) {
                displayVideos(result.data);
            } else {
                throw new Error('获取视频数据失败');
            }
        } catch (error) {
            console.error('加载视频失败:', error);
            displayError();
        }
    }

    // 显示视频
    function displayVideos(videos) {
        const videoContainer = document.getElementById('videoContainer');
        videoContainer.innerHTML = ''; // 清空加载提示

        if (!videos || videos.length === 0) {
            videoContainer.innerHTML = '<div class="loading">暂无视频内容</div>';
            return;
        }

        videos.forEach(video => {
            const videoWrapper = document.createElement('div');
            videoWrapper.className = 'video-wrapper';

            videoWrapper.innerHTML = `
                    <video controls>
                        <source src="${video.video_src}" type="video/mp4">
                        您的浏览器不支持视频播放
                    </video>
                    <div class="video-caption">${video.name}</div>
                `;

            videoContainer.appendChild(videoWrapper);
        });

        // 重新绑定视频悬停效果
        bindVideoHoverEffects();
    }

    // 显示错误信息
    function displayError() {
        const videoContainer = document.getElementById('videoContainer');
        videoContainer.innerHTML = '<div class="loading">视频加载失败，请刷新页面重试</div>';
    }

    // 绑定视频悬停效果
    function bindVideoHoverEffects() {
        const videos = document.querySelectorAll('video');
        videos.forEach(video => {
            video.addEventListener('mouseover', () => video.controls = true);
            video.addEventListener('mouseout', () => video.controls = false);
        });
    }

    function refreshVideos() {
        const videoContainer = document.getElementById('videoContainer');
        videoContainer.innerHTML = '<div class="loading">刷新视频中</div>';
        loadVideos();
    }
</script>

<!-- 页脚版权信息 -->
<footer style="text-align: center; padding: 2rem; background-color: #f0f0f0; color: #666; font-size: 0.9rem;">
    <p> <a href="./login.html" > 点击登录后台管理系统 </a> </p>
    <p>曹惠宁 杜梓沫 杨雨昔 刘晓雨 宋金乔 张墨涵 李雨桐 <a href="./colorEgg.html" style="color: inherit; text-decoration: none; cursor: pointer;">作品</a> © 2025</p>
    <p>黑河学院经济管理学院、文化旅游学院、计算机与信息工程学院 软件项目开发社团 版权所有</p>
</footer>
</body>
</html>